
local logging = require 'logging'
local print
    = print

local filename = "log.txt"
local f = assert(io.open(filename, "a"), "unable to write to log file")
f:setvbuf("line")

return logging.new(
  function(self, level, message)
    local s = logging.prepareLogMsg("%date [%level] %message\n", os.date("%d/%m/%Y %H:%M:%S"), level, message)
    f:write(s)
    io.write(s)
    return true
  end)
